package cn.iocoder.yudao.module.activity.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.activity.entity.ActivityDO;
import cn.iocoder.yudao.module.activity.service.ActivityService;
import cn.iocoder.yudao.module.activity.vo.ActivityPageReqVO;
import cn.iocoder.yudao.module.activity.vo.ActivityRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "APP - 招聘活动")
@RestController
@RequestMapping("/app/activity/")
@Validated
public class AppActivityController {

    @Resource
    private ActivityService activityService;


    @GetMapping("/get")
    @Operation(summary = "获得招聘活动")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<ActivityRespVO> get(@RequestParam("id") Long id) {
        ActivityDO activityDO = activityService.get(id);
        return success(BeanUtils.toBean(activityDO, ActivityRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得招聘活动")
    public CommonResult<List<ActivityDO>> getList(@Valid ActivityPageReqVO pageReqVO) {
        return success(activityService.getList(pageReqVO));
    }


}